// 1.createRouter 生成router实例对象
// 2.createWebHashHistory 生成hash模式的路由配置对象

import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout'
import Login from '@/views/Login'
import Category from '@/views/Category'
import Home from '@/views/Home'
import Good from '@/views/Good'
const routes = [
  {
    path: '/',
    component: Layout,
    name: 'layout',
    children: [
      {
        path: '', // 为什么要为空？ 当二级路由的part置为空时，将作为默认二级路由渲染
        name: 'home',
        component: Home
      },
      {
        path: 'category/:id',
        name: 'category',
        component: Category
      },
      {
        path: 'good/:id',
        component: Good,
        name: 'good'
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: Login
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
